package org.leiyang.gateway.config;

import org.leiyang.common.etcd.IConfigCenter;
import org.leiyang.common.etcd.MyEtcdBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 所需的Bean
 */
@Configuration
public class BeanConfig {

    @Value("${etcd.server}")
    private String etcdServer;

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Bean
    public IConfigCenter etcdClient() {
        logger.info("[gateway] etcd address will start : {}", etcdServer);
        //连接多个时，逗号分隔
        return MyEtcdBuilder.build(etcdServer);
    }
}
